Example Program
Longest Common Subsequence
Longest common subsequence code example
This code example illustrates the longest common subsequence algorithm
1#include <seqan/graph_algorithms.h>
2#include <iostream>
3
4using namespace seqan;
5
6int main() {
Creation two sequences
7    String<char> seq1("abacx");
8    String<char> seq2("baabca");
Out-parameter: A string of positions belonging to the longest common subsequence
9    String<std::pair<unsigned int, unsigned int>, Block<> > pos;
Longest common subsequence
10    longestCommonSubsequence(seq1, seq2, pos);
Console ouptut
11    std::cout << seq1 << std::endl;
12    std::cout << seq2 << std::endl;
13    std::cout << "Lcs:" << std::endl;
14    for(int i = length(pos)-1; i>=0; --i) {
15        std::cout << seq1[pos[i].first] <<  ',';
16    }
17    std::cout << std::endl;
18    for(int i = length(pos)-1; i>=0; --i) {
19        std::cout << seq2[pos[i].second] <<  ',';
20    }
21    std::cout << std::endl;
22    return 0;
23}
SeqAn - Sequence Analysis Library - www.seqan.de